package cn.jsu.oj.dispatchServer.satellite.mode.strategy;

import cn.jsu.oj.dispatchServer.satellite.netty.SitePointHandler;
import cn.jsu.oj.dispatchServer.satellite.server.Client;
import cn.jsu.oj.dispatchServer.satellite.server.SatelliteServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 抽象策略
 *
 * @author shan
 * @date 2022/07/13
 */
@Component("absStrategy")
public abstract class AbsStrategy implements cn.jsu.oj.dispatchServer.satellite.mode.strategy.Strategy {

    @Autowired
    SatelliteServer satelliteServer;
    
    protected Object premise;
    
    @Override
    public void setPremise(Object object) {
        this.premise = object;
    }

    protected Boolean activeClientCheck(String missTarget) {
        for (Map.Entry<String, Client> stringClientEntry : SitePointHandler.CLIENT_MAP.entrySet()) {
            if (stringClientEntry.getKey().equals(missTarget)) {
                return true;
            }
        }
        return false;
    }
}
